XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX SPRITE DATA FOR CASTLEVANIA II - SIMON'S QUEST XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Document regarding sprites in Castlevania II, chiefly those of Enemies, Items, and NPCs. Covered in this document are: I. Sprite composition II. Sprite behavior III. Sprite collision Pertinent addresses for info in this document... Sprite animation: 0x1DDB2 Sprite frames: 0x2C40 Sprite placement: 0x41A2 Collision space: 0x4AD0 Behavior protocol: 0x41E3 Collision damage: 0x4C0F ==================================== I. SPRITE COMPOSITION ==================================== SPRITE FRAMES ----------------------------------------------------------------------------------- 00- blank 01- Simon (walking) 02- Simon (Walking) 03- Simon (walking) 04- Simon (walking/standing) 05- Simon (duck/jump) 06- Simon (downstairs) 07- Simon (downstairs) 08- Simon (upstairs) 09- Simon (upstairs) 0A- Simon (whipping/throwing) 0B- Simon (whipping/throwing) 0C- Simon (whipping/throwing) 0D- Simon (walking) 0E- skeleton 0F- skeleton 10- fishman 11- fishman 12- bat (mansion) 13- bat (mansion) 14- bat (mansion) 15- town raven 16- town raven 17- town raven 18- town raven 19- mansion zombie 1A- mansion zombie 1B- floating block 1C- town lady 1D- town lady 1E- merchant 1F- merchant 20- priest 21- priest 22- town man 23- town man 24- town old man 25- town old man 26- town knight 27- town knight 28- town old lady 29- fireball 2A- Simon (whip jumping) 2B- Simon (whip jumping) 2C- Simon (whip jumping) 2D- Simon (duck/jump) 2E- spider 2F- spider 30- book 31- gargoyle 32- gargoyle 33- dracula 34- dracula (shoot) 35- pitchfork armor 36- pitchfork armor 37- skeleton bone 38- skeleton bone 39- skeleton bone 3A- garlic 3B- dracula part ball 3C- blob 3D- blob 3E- blob (jump) 3F- zombie 40- zombie 41- holy water 42- oak stake 43- floating blocks (flat) 44- death 45- death 46- swamp worm 47- swamp worm 48- spider web 49- skull 4A- skull 4B- Simon (ending) 4C- Simon (ending) 4D- Simon (ending) 4E- Simon (ending) 4F- medusa 50- medusa 51- floating blocks (vertical) 52- leather whip 53- leather whip 54- leather whip 55- leather whip segment 56- skeledragon head (fireball) 57- skeledragon head 58- swamp ghoul 59- swamp ghoul 5A- swamp ghoul 5B- swamp ghoul 5C- splash 5D- two headed lizard 5E- two headed lizard 5F- ? 60- ? 61- swamp worm 62- swamp worm 63- wolf 64- wolf 65- werewolf 66- werewolf 67- fishman (fireball) 68- thorn whip segment 69- chain whip 6A- chain whip 6B- chain whip 6C- chain whip segment 6D- morning star whip 6E- morning star whip 6F- morning star whip 70- morning star whip segment 71- flame whip 72- flame whip 73- Simon (getting hit) 74- Simon (dead) 75- spider web string 76- spider web string 77- spider web string 78- dead enemy flame 79- dead enemy flame 7A- dracula shot 7B- dracula shot 7C- dracula shot 7D- dracula shot 7E- ? 7F- ferry man on front platform 80- ferry man back platform 81- falling rock 82- falling rock 83- ? 84- ? 85- spider web string 86- blob (rising) 87- blob (ceiling) 88- blob (ceiling) 89- blob (ceiling jump) 8A- blob (descending) 8B- heart (2) 8C- heart (4) 8D- heart (6) 8E- hand 8F- hand 90- raven 91- raven 92- raven 93- clawed skeleton 94- clawed skeleton 95- clawed skeleton 96- clawed skeleton 97- harpee (flying) 98- harpee (flying) 99- harpee (flying) 9A- harpee (flying) 9B- ? 9C- tornado 9D- flameman 9E- flameman 9F- spike A0- spike A1- rising body part bag A2- Simon (shield/standing) A3- Simon (shield/ducking) A4- sacred flame A5- sacred flame A6- sacred flame A7- sacred flame A8- sacred flame A9- sacred flame AA- sacred flame AB- sacred flame AC- sacred flame AD- knife AE- dracula tomb (after hand appears) AF- dracula tomb (after hand appears) ? B0- Simon (whip downstairs) B1- Simon (whip downstairs) B2- Simon (whip downstairs) B3- Simon (whip downstairs) B4- Simon (whip upstairs) B5- Simon (whip upstairs) B6- Simon (whip upstairs) B7- Simon (whip upstairs) B8- diamond B9- diamond BA- diamond BB- diamond BC- mummy BD- mummy BE- thornweed BF- thornweed C0- swamp ghoul (joma marsh) C1- swamp ghoul (joma marsh) C2- swamp ghoul (joma marsh) C3- blob C4- blob C5- blob (jump) C6- eyeball C7- eyeball C8- bat (woods) C9- bat (woods) CA- camilla CB- unassigned CC- unassigned CD- unassigned CE- unassigned CF- death hatchet D0- death hatchet D1- death hatchet D2- death hatchet D3- dracula parts flame D4- dracula parts flame D5- dracula parts flame D6- dracula parts flame D7- dracula hand (ending) D8- dracula hand (ending) D9- dracula hand (ending) DA- dracula hand (ending) DB- dracula hand (ending) DC- dracula hand (ending) DD- dracula tomb (ending) DE- magic cross DF- Camilla drop E0- ? E1- ? E2- ? E3- ? E4- ? E5- ? E6- ghost E7- ghost E8- ? E9- dracula death flame EA- dracula death flame EB- dracula death flame EC- dracula death flame ED- harpee (walking) EE- harpee (walking) EF- passowrd cursor F0- passowrd arrow F1- title screen arrow F2- ? F3- ? F4- ? F5- ? F6- ? F7- ? F8- ? SPRITE FRAME DEFINITION ----------------------------------------------------------------------------------- x2C40 = Pointer table for each sprite frame. The addresses, indexed 00 to FF, are of data that composes a sprite frame. For example: Sprite frames x0E and x0F (1FB2 and 2DB2) are for the skeleton. At xF22F (aka 1FB2) You have this data for the first skeleton frame: 04 DA D1 03 F8 DB B3 00 FB B5 F8 FB B7 00 Each row is for each 8x16 tile. The first row initiates the sprite with a couple extra variables. Here's what they indicate: 04 = number of tiles used for the sprite. This indicator only appears once at the start of every sprite frame. DA = Vertical position of sprite from center. Bit 1 must be left off to include the palette indicator byte. D1 = Sprite tile. Set bit 0 to draw the 8x16 tile from the sprite GFX table. Leave bit 0 off fto draw the 8x16 tile from the BG GFX table (90 would draw the positional equivalent from the BG tileset). 03 = The second nybble is the palette (I believe there are four 0-3). Set bit 7 (add x80) to flip sprite tiles in the set vertically. Set bit 6 (add x40) to flip sprite tiles horizantally. Set bit 5 (add x20) to have sprite tiles hide behind BG graphics (only bosses 2 and 3 use this so far). F8 = Horizontal position of sprite from center. This usually is incremented by 8 for sprite tiles that are directly next to each other. Next in the sequence we have: DB = The vertical position, bit 1 is set so no palette/inversion byte is used for this tile; It will simply adopt the same palette/inversion as the last tile, and so will every other tile for this frame, unless it is redefined at a later point (a lot of sprites contain multiple palettes and inversions). B3 = The next tile. 00 = The horizantal position. The other two tile are positioned the same way. The next frame (2DB2) of the skeleton appears like this at 0x323D: 04 DC B1 03 F8 DD B3 00 FB B9 F8 FB BB 00 A subtle difference from the first frame is that the upper half is positioned lower than it is in the first one by one pixel, actually overlapping the bottom half of the sprite (Note DC and DD in the first couple sprites instead of DA and DB). This was done to make the skeleton hunch a little when he walks. But this isn't the only format for sprites, this is just the most common. Let's take a look another enemy's frames, the Wolfman (5DB6 and 64B6): 0x366D: 84 1F B2 A1 A3 A5 A7 0x366D: 84 1F B2 A9 AB AD AF In this case, the tiles are arranged in the exact same manner as the first frame of the skeleton, but they are just using less bytes to save rom (Nice that they programmed this feature, unlike in CV1 engine). Here's the breakdown: 84 = Number of tiles, with bit 7 set to adopt the same exact format of another sprite frame, but now using different tiles. 1F B2 = The pointer of the sprite frame to adopt (in this case, the first skeleton frame). A1 A3 A5 A7= Tiles used for this frame, in the same order they would sequentially appear in the last frame. The second Wolfman frame uses the same tile arrangement but with different tiles. SPRITE ANIMATION DEFINITION ----------------------------------------------------------------------------------- x1DDB2 = Start of the sprite animation table. Each animation in the table is composed of the 3 bytes. The first animation in the table is the player's walking animation, for example, and it appears like this: 03 01 0A 03 = number of frames to be used for the animation (it's zero based, so it's actually 4 frames). 01 = The index number of the sprite frame to start the animation. So, with 4 frames of animation used, the frames that appear are: 02 03 04 05. They must be sequential, there is no workaround. 0A = The speed/framerate of the animation. the lower the number, the quicker. 80 is used for one frame sprite animations (I guess these exist for some reason, but probably a good idea not to mess with it until it's ruled out to be safe). ==================================== II. SPRITE BEHAVIOR ==================================== The address for each sprite's behavior in the game is indexed with X from $3B4. Each sprite enemy, item, and NPC has a unique identifier for its behavior, as shown in the table below. This value is the value loaded into $3B4, X. The addresses for each sprite's behavior are at a pointer table at x41E3. These pointers are indexed based on the sprite's behavior value ($3B4, X) SPRITE BEHAVIOR INDEX ------------------------------------ 00- Nothing 01- Town Raven 02- Swamp Worm 03- Skeleton 04- Fishman 05- Pitchfork Armor 06- Snakeman 07- Splash 08- Eyeball 09- Bat 0A- Medusa 0B- ? 0C- Skeleton Bone 0D- Jumping Skeleton 0E- Spider 0F- Gargoyle 10- Skull 11- Hanging Bat 12- Wolf 13- Werewolf 14- Mansion Zombie 15- Swamp Ghost 16- Freddie 17- Zombie 18- Swamp Ghoul 19- Skeledrag Segment 1A- Skeledrag Segment 1B- Eagle 1C- Deborah Cliff Tornado 1D- Flameman 1E- Secret Merchant 1F- Blob 20- Spikeshot 21- Sideways block 22- Floating block 23- ? 24- Sign 25- Orb 26- Sacred Flame 27- Book 28- Town Man 29- Town Woman 2A- Town Man 2B- Town Man 2C- Town Old Woman 2D- Priest 2E- Merchant 2F- Town Knight 30- Fireball 31- Fireball 32- Fireball (from flame man) 33- Spider Web 34- Single Floating Block 35- Town Old Man 36- Flame after killing enemy 37- Heart after killing enemy 38- Hand 39- Ghost 3A- Mummy 3B- Eagleman 3C- Ferry Man 3D- Ferry Boat 3E- Falling Rock 3F- Thornweed 40- Swamp Worm (high) 41- High Jump Blob 42- Camilla 43- Marsh 44- Death 45- Camilla drops 46- Death hatchet 47- Dracula 48- Dracula shot 49- Item after killing boss 4A- Skeledrag 4B- Money bags rising 4C- Flame that burns dracula's parts 4D- Flame that ends game BEHAVIOR ROUTINES COMMON IN SPRITES ------------------------------------ 45 84 = projectile angled 29 86 = necessary for an enemy to walk 12 8D = decides which direction to travel (up/down) 21 8E = non following projectile 26 8E = following projectile CF D9 = sprite palette changes constantly (at end of routine) 2A DD = necessary for constant animation 6F DE = Running speed 8B DE = Reverse direction after bumping into a wall B7 DE = Checks if player is right or left from itself CA DE = Sprite has initiated D4 DE = Sprite Frame D8 DE = Sprite Animation A3 DF = repeat? 42 DF = complete abortion of sprite 62 DF = After a hit, the enemy dissipates! C3 DF = Total screen wipe of sprites CE DF = Fall (coupled with $15?) E4 DF = Jump height (coupled with $08) 10 E0 = flip sprite 1F E0 = Flip direction 76 E0 = stores values for up/down movement F4 E0 = needed for movement constant SPRITE PLACEMENT IN LEVELS ------------------------------------ 0x41A2 is the pointer list that starts it all for each area 0x4EBB is enemy placement in the towns. 0x52C5 is the mansions. etc. ==================================== III. SPRITE COLLISION ==================================== A sprite's collision in Castlevania II is found in the pointer table at 0x4AD0. The pointers in this table are indexed based on spritde behavior ($3B4, X). They point to a string of numbers that correspond to an index for defined collision space for the sprite. For example: For the fishman Behavior index = 04 Collision pointer in x4AD0 table = 778B Collision space index at x4B87 = 11, 11, 11 etc. The collision space for the fishman sprite is 11. Which of these 11s is used is based on another sprite index, (3FC, X) which is also corresponds to a sprite's animation frame index. Since the fishman only has two animations frames when it walks, it uses only the first and second 11. Some of the tables will have different numbers, which means the sprite will use multiple collisions throughout its cycle. The 11 will be used as an index of another table at x4B8E. 3 bytes are taken from this table: - (Byte 1) The Y-position of the collision in reference to the sprite's centerpoint - (Byte 2) The height of the collision space - (Byte 3) The width of the collision space For the skeleton, it will gather the x11th set of 3 bytes from the x4B8E table, located at x4BC1: FD 0C 06 Which means: -(FD) The Y-position of the collision is 3 pixels above the sprite's centerpoint. -(0C) The sprite's collision height is 0C pixels high -(06) The sprite's collision width is 0C pixels high Coding for collision in the game is found just below. COLLISION SPACE BYTES ------------------------------------ byte 1: height, bot byte 2: height, top byte 3: width 00- 2x4 (like skeleton) 01- 2x2 (like book)- offcenter 02- 03- 1x1 (like fireball) 04- 2x2 (like eyeball) 05- 1x2 (like swamp worm) 06- 1x1 (like flat blob) 07- 4x4 (like camilla) 08- 3x4 (like snakeman) 09- 0A- 2x1 (like hand) 0B- 0x0 (like nothing) 0C- 3x4 (like thornweed)- slightly shorter 0D- 4x6 (like dracula or death) 0E- 2x5 (like mummy) 0F- 2x2 (like sac. flame)- offcenter 10- 1x1 (like flying blob) 11- 2x4 (like fishman)- slightly dif. than skel. 12- ?x? (like freddie)